<?php
/*=============================================================================
|| ##################################################################
||	phpFoX Konsort
|| ##################################################################
||	
||	Copyright		: (C) 2005-2007 PHPFOX Limited a Reality Fox Creation
||	Contact			: info@phpfox.com
||
||	- phpFoX and all of its source code and files are protected by Copyright Laws. 
||
||	- The license for phpFoX permits you to install this software on a single domain (.com, .org, .net, etc.). 
||
||	- You may also not remove this copyright screen which shows the copyright information and credits for phpFoX (RealityFOX Creations). 
||
||	- phpFoX Konsort is NOT a FREE software - http://www.phpfox.com/license/
||
|| ##################################################################
=============================================================================*/

/* $File: ./include/modules/Log/classes/PhpFox_ComponentRecentVisitors.class.php, $Author:  $ */



/** Component for browsing profile sessions
 * 
 * Parameters:
 * 1. sPage (reqired) - page name (forum, poll, quiz etc.)
 * 2. iNumUser (optional) - max. number of recent user (default - 8)
 * 3. RowSize (optional) - users per page (default - 4)
 * 4. iPicSize (optional) - user pictures size (deafult - 50)
 * 
 * @version $Id: PhpFox_ComponentRecentVisitors.class.php 46 2007-12-14 23:12:21Z phpfoxsv $
 * @package module.log
 *   
 */
class PhpFox_Mod_Log_ComponentRecentVisitors extends BaseComponent
{
    /** Processing method
     */
    function process()
    {
        
        $iNumUser = $this->getParam('iNumUser', 8);
        $iRowSize = $this->getParam('iRowSize', 4);
        $iPicSize = $this->getParam('iPicSize', 50);
        $sPage    = $this->getParam('sPage', 'login');
        
        $oSrvLog = $this->_oModule->getService('Log');
        /* @var $oSrvLog PhpFox_Mod_Log_ServiceLog */
        
        $sUser = $this->getParam('sUser');
        if ($sUser)
        {
            $aUsers = $this->oDatabase->getRows('SELECT user FROM '. App::getT('session') .' WHERE viewing = "'. $sUser .'" ORDER BY `time` DESC LIMIT '. $iNumUser .'');
        }
        else
        {
            $aUsers = $oSrvLog->getRecentUserList($sPage, $iNumUser);
        }
        

        $oTpl = &$this->_oModule->getTemplate();
        $oTpl->assign(array(
            'aUsers'      => $aUsers,
            'iRowSize'    => $iRowSize,
            'iPicSize'    => $iPicSize,
            'sUserPicUrl' =>  App::getParam('user.pic.url'),
        ));
        $srcHtml = $oTpl->fetch('RecentVisitors.html');
        return $srcHtml;
    }
}
?>